﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch07
{
    class Class3
    {
        static void Main(string[] args)
        {
            Console.Write("请输入字符串:");
            string str = Console.ReadLine();
            Console.Write("要查询的字符：");
            string find = Console.ReadLine();

            int count = 0;
            int index = 0;
            string indexStr = "";

            do
            {
                index = str.IndexOf(find,index);
                if (index == -1)
                {
                    break;
                }
                indexStr += index + "\t";
                index += find.Length;
                count++;
            } while (true);

            Console.WriteLine("总共有" + count + "个");
            Console.WriteLine("下标分别是：" + indexStr);

            /*
            for (int i = 0; i < str.Length; i++)
            {
                if (str.IndexOf(Name)!=-1)
                {
                    arr[i] = str.IndexOf(Name)+num;
                    str=str.Remove(str.IndexOf(Name),1);
                    num++;
                }
            }
            Console.WriteLine("{0}个有{1}个：",Name,num);
            Console.WriteLine("位置如下：");
            for (int i = 0; i < num; i++)
            {
                Console.WriteLine(arr[i]);
            }
            */
        }
    }
}
